
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>K8s下的Python资源限制 · MLSQL Engine 文档</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/image.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="datamode.html" />
    
    
    <link rel="prev" href="write_excel.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    MLSQL Engine产品简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../howtouse/">
            
                <a href="../howtouse/">
            
                    
                    MLSQL Engine基本安装
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../howtouse/configuration.html">
            
                <a href="../howtouse/configuration.html">
            
                    
                    启动参数详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../howtouse/deploy.html">
            
                <a href="../howtouse/deploy.html">
            
                    
                    Local
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../howtouse/k8s_deploy.html">
            
                <a href="../howtouse/k8s_deploy.html">
            
                    
                    K8s部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../howtouse/yarn_deploy.html">
            
                <a href="../howtouse/yarn_deploy.html">
            
                    
                    Yarn部署
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../security/README.md">
            
                <span>
            
                    
                    MLSQL Engine安全加固
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../security/token_control.html">
            
                <a href="../security/token_control.html">
            
                    
                    接口访问Token设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../security/custom_control.html">
            
                <a href="../security/custom_control.html">
            
                    
                    自定义接口访问策略
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../auth/">
            
                <a href="../auth/">
            
                    
                    MLSQL Engine数据访问控制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" >
            
                <span>
            
                    
                    解析时表权限
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" >
            
                <span>
            
                    
                    运行时表权限表以及列权限
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" >
            
                <span>
            
                    
                    客户端开发
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" >
            
                <span>
            
                    
                    服务端开发
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../api/README.md">
            
                <span>
            
                    
                    MLSQL Engine Rest接口详解
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../api/run-script.html">
            
                <a href="../api/run-script.html">
            
                    
                    /run/script
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="./">
            
                <a href="./">
            
                    
                    MLSQL Python支持
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="env.html">
            
                <a href="env.html">
            
                    
                    环境依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="etl.html">
            
                <a href="etl.html">
            
                    
                    数据处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="train.html">
            
                <a href="train.html">
            
                    
                    模型训练
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="pyjava.html">
            
                <a href="pyjava.html">
            
                    
                    PyJava API简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="read_excel.html">
            
                <a href="read_excel.html">
            
                    
                    结合Python读取Excel
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="write_excel.html">
            
                <a href="write_excel.html">
            
                    
                    结合Python保存Excel
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.7" data-path="resource.html">
            
                <a href="resource.html">
            
                    
                    K8s下的Python资源限制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="datamode.html">
            
                <a href="datamode.html">
            
                    
                    dataMode 详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="py_paralell.html">
            
                <a href="py_paralell.html">
            
                    
                    Python并行度你所需要知道的
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../plugin/">
            
                <a href="../plugin/">
            
                    
                    插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../plugin/online_install.html">
            
                <a href="../plugin/online_install.html">
            
                    
                    网络安装插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../plugin/offline_install.html">
            
                <a href="../plugin/offline_install.html">
            
                    
                    离线安装插件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >K8s下的Python资源限制</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="python&#x8D44;&#x6E90;&#x9650;&#x5236;">Python&#x8D44;&#x6E90;&#x9650;&#x5236;</h1>
<p>&#x5728;MLSQL&#x4E2D;&#x7684;Python&#x4EE3;&#x7801;&#x4F1A;&#x5355;&#x72EC;&#x5728;Driver&#x6216;&#x8005;Executor&#x8282;&#x70B9;&#x4E0A;&#x542F;&#x52A8;&#x4E00;&#x4E2A;Python&#x8FDB;&#x7A0B;&#x8FD0;&#x884C;&#x3002;&#x9ED8;&#x8BA4;&#x603B;&#x6570;&#x91CF;&#x4E0D;&#x8D85;&#x8FC7;&#x8282;&#x70B9;&#x7684;&#x6838;&#x6570;&#x3002;</p>
<p>&#x4E0D;&#x8FC7;&#x9057;&#x61BE;&#x7684;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x6CE8;&#x610F;&#x63A7;&#x5236;Python&#x8FDB;&#x7A0B;&#x7684;&#x8D44;&#x6E90;&#x5360;&#x7528;&#xFF0C;&#x800C;MLSQL Engine&#x53C8;&#x8DD1;&#x5728;K8s(Yarn&#x4E0A;&#x4E5F;&#x662F;&#x7C7B;&#x4F3C;&#x60C5;&#x51B5;)&#x4E0A;&#xFF0C;&#x5F88;&#x53EF;&#x80FD;&#x5BFC;&#x81F4;&#x5BB9;&#x5668;&#x88AB;&#x6740;&#xFF0C;&#x5982;&#x679C;&#x662F;driver&#x8282;&#x70B9;&#x88AB;&#x6740;&#xFF0C;&#x90A3;&#x4E48;&#x4F1A;&#x5BFC;&#x81F4;&#x6574;&#x4E2A;Engine&#x5931;&#x8D25;&#x3002;&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#xFF1A;</p>
<ol>
<li>&#x8FDE;&#x63A5;Ray&#x96C6;&#x7FA4;&#x5E76;&#x4E14;&#x5C06;&#x5904;&#x7406;&#x903B;&#x8F91;&#x90FD;&#x653E;&#x5230;Ray&#x91CC;&#x53BB;&#x5B8C;&#x6210;&#xFF08;&#x5B98;&#x65B9;&#x63A8;&#x8350;&#xFF09;</li>
<li>&#x5BF9;Python&#x4EE3;&#x7801;&#x6240;&#x5904;&#x7684;&#x8FDB;&#x7A0B;&#x505A;&#x8D44;&#x6E90;&#x9650;&#x5236;</li>
</ol>
<p>&#x5BF9;&#x4E8E;1&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;RayContext.foreach/RayContext.map_iter &#x505A;&#x5904;&#x7406;&#x3002;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x6570;&#x636E;&#x7684;&#x4EA4;&#x4E92;&#x65E0;&#x9700;&#x7ECF;&#x8FC7;client&#x3002;</p>
<p>&#x5BF9;&#x4E8E;2&#xFF0C;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x5728;&#x5BB9;&#x5668;&#x91CC;&#x8BBE;&#x7F6E;&#x73AF;&#x5883;&#x53D8;&#x91CF; <code>export PY_EXECUTOR_MEMORY=300</code> &#x4EA6;&#x6216;&#x662F; <code>!python conf &quot;py_executor_memory=300&quot;;</code> &#x8FD9;&#x91CC;&#x8868;&#x793A;Python &#x5185;&#x5B58;&#x4E0D;&#x5E94;&#x8BE5;&#x8D85;&#x8FC7;300M. &#x5C3D;&#x7BA1;&#x5982;&#x6B64;&#xFF0C;&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x6848;&#x8FD8;&#x662F;&#x6709;&#x7F3A;&#x9677;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x6709;8&#x6838;&#xFF0C;&#x5F53;&#x591A;&#x4E2A;&#x7528;&#x6237;&#x5E76;&#x884C;&#x4F7F;&#x7528;&#x65F6;&#xFF0C;&#x6700;&#x591A;&#x4F1A;&#x5360;&#x7528;2.4G&#x5185;&#x5B58;&#xFF0C;&#x5F88;&#x53EF;&#x80FD;&#x5BFC;&#x81F4;&#x5BB9;&#x5668;&#x88AB;&#x6740;&#x6B7B;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x65B9;&#x5F0F;&#x4E00;&#xFF0C;&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x5178;&#x578B;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-python">load delta.`public.consumer_complains` <span class="hljs-keyword">as</span> cc;
select * <span class="hljs-keyword">from</span> cc limit <span class="hljs-number">100</span>
-- union all select * <span class="hljs-keyword">from</span> cc 
-- union all select * <span class="hljs-keyword">from</span> cc 
-- union all select * <span class="hljs-keyword">from</span> cc 
<span class="hljs-keyword">as</span> newcc;

-- ray &#x914D;&#x7F6E;
!python env <span class="hljs-string">&quot;PYTHON_ENV=source activate dev&quot;</span>;
!python conf <span class="hljs-string">&quot;schema=st(field(ProductName,string),field(SubProduct,string))&quot;</span>;
!python conf <span class="hljs-string">&quot;runIn=driver&quot;</span>;
!python conf <span class="hljs-string">&quot;dataMode=data&quot;</span>;

-- ray&#x5904;&#x7406;&#x6570;&#x636E;&#x4EE3;&#x7801;
!ray on newcc <span class="hljs-string">&apos;&apos;&apos;
import ray
from pyjava.api.mlsql import RayContext
import numpy as np;


ray_context = RayContext.connect(globals(),&quot;192.168.209.29:12879&quot;)


def echo(rows):
    for row in rows:
      row1 = {}
      row1[&quot;ProductName&quot;]=&quot;jackm&quot;
      row1[&quot;SubProduct&quot;] = row[&quot;SubProduct&quot;]
      yield row1


ray_context.map_iter(echo)
&apos;&apos;&apos;</span> named mlsql_temp_table2;

--&#x7ED3;&#x679C;
save overwrite mlsql_temp_table2 <span class="hljs-keyword">as</span> parquet.`/tmp/mlsql_temp_table2`;
load  parquet.`/tmp/mlsql_temp_table2` <span class="hljs-keyword">as</span> mlsql_temp_table3;
</code></pre>
<p>ray_context.map_iter &#x4F1A;&#x4FDD;&#x8BC1;&#x4F60;&#x7684;&#x6570;&#x636E;&#x5904;&#x7406;&#x903B;&#x8F91;&#x90FD;&#x8FD0;&#x884C;&#x5728;Ray&#x96C6;&#x7FA4;&#x4E0A;&#x3002;&#x5BF9;&#x4E8E;&#x4E0A;&#x9762;&#x7684;&#x6A21;&#x5F0F;&#xFF0C;&#x4ECD;&#x7136;&#x6709;&#x4E2A;&#x7EC6;&#x8282;&#x9700;&#x8981;&#x4E86;&#x89E3;&#xFF0C;&#x5C31;&#x662F;map_iter&#x91CC;&#x51FD;&#x6570;&#x8FD0;&#x884C;&#x7684;&#x6B21;&#x6570;&#xFF0C;&#x53D6;&#x51B3;&#x4E8E;&#x6570;&#x636E;&#x8868;<code>newcc</code>&#x7684;&#x5206;&#x7247;&#x6570;&#x3002;&#x5982;&#x679C;&#x4F60;&#x5E0C;&#x671B;&#x5728;&#x51FD;&#x6570;&#x91CC;&#x62FF;&#x5230;&#x6240;&#x6709;&#x6570;&#x636E;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x5C06;newcc &#x7684;&#x5206;&#x7247;&#x6570;&#x8BBE;&#x7F6E;&#x4E3A;1&#x3002;</p>
<p>&#x5C06;newcc&#x5206;&#x7247;&#x6570;&#x8BBE;&#x7F6E;&#x4E3A;1&#x7684;&#x65B9;&#x5F0F;&#x6709;&#x4E24;&#x79CD;&#xFF1A;</p>
<ol>
<li></li>
</ol>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="write_excel.html" class="navigation navigation-prev " aria-label="Previous page: 结合Python保存Excel">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="datamode.html" class="navigation navigation-next " aria-label="Next page: dataMode 详解">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"K8s下的Python资源限制","level":"1.6.7","depth":2,"next":{"title":"dataMode 详解","level":"1.6.8","depth":2,"path":"python/datamode.md","ref":"python/datamode.md","articles":[]},"previous":{"title":"结合Python保存Excel","level":"1.6.6","depth":2,"path":"python/write_excel.md","ref":"python/write_excel.md","articles":[]},"dir":"ltr"},"config":{"plugins":["image-class","lightbox"],"styles":{"website":"styles/image.css"},"pluginsConfig":{"image-class":{},"lightbox":{"jquery":true,"sameUuid":false},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"MLSQL Engine 文档","gitbook":"*","description":"MLSQL Engine 官方文档"},"file":{"path":"python/resource.md","mtime":"2020-09-01T10:54:17.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-09-03T03:59:44.434Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

